package com.lingjtx.common.api.config;

import feign.Logger;
import feign.Request;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@EnableFeignClients
@ComponentScan(basePackages = FeignPackage.GLOBAL_PACKAGE)
@Configuration
public class FeignConfig {


    /**
     * Feign 超时时间配置
     */
    @Bean
    public Request.Options feignOptions() {
        return new Request.Options(5000, TimeUnit.MILLISECONDS, 10000, TimeUnit.MILLISECONDS, true);
    }

    @Bean
    Logger.Level feignLoggerLevel() {
        // NONE：不记录日志
        // BASIC：仅记录请求方法、URL、状态码和执行时间
        // HEADERS：记录 BASIC 级别信息 + 请求和响应头
        // FULL：记录 HEADERS 级别信息 + 请求和响应体
        return Logger.Level.FULL;
    }
}
